package com.xiaobawang.data_server.controller;

import com.xiaobawang.data_server.entity.User;
import com.xiaobawang.data_server.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "user")
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("添加用户信息")
    @PutMapping("/addUser")
    public int addUser(User user) {
        return userService.insertUser(user);
    }

    @ApiOperation("删除用户信息")
    @GetMapping("/deleteUser")
    public int deleteUser(int id) {
        return userService.deleteUser(id);
    }

    @ApiOperation("修改用户信息")
    @PutMapping("/alterUser")
    public int alterUser(User user) {
        return userService.alterUser(user);
    }

    @ApiOperation("查看用户信息")
    @GetMapping("/selectUser")
    public User selectUser(int id) {
        return userService.selectUser(id);
    }

}
